import Page
from Page import Personal
from Base.Base import Base
from selenium.webdriver.common.by import By


class PersonalTask(Base):
    """
     任务中心
    """

    # TODO:

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.task_home_btn = (By.XPATH, Personal.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.task_back_btn = (By.XPATH, Personal.RESOURCE_ID.format('ivBack'))

        #打卡天数列表文本
        self.task_list_day_text = (By.XPATH, Personal.punch_list_day_text.format(1))

        # 打卡天数列表图标
        self.task_list_day_punch_icon = (By.XPATH, Personal.punch_list_day_img.format(1))

        # 日常任务金币图标
        self.task_gold_img = (By.XPATH, Personal.RESOURCE_ID.format("iv_center"))

        # 日常任务提示语
        self.task_day_punch_prompt_text = (By.XPATH, Personal.RESOURCE_ID.format("tvScore"))

        # 日常任务打卡按钮
        self.task_punch_button_btn = (By.XPATH, Personal.RESOURCE_ID.format("bt_submit"))

        # 连续打卡提示
        self.task_keep_punching_text = (By.XPATH, Personal.RESOURCE_ID.format("tv_tips"))

        # 连续打卡角标
        self.task_keep_punching_glod_icon = (By.XPATH, Personal.RESOURCE_ID.format("iv_small_coin"))

        # 日常任务tab
        self.task_daily_tasks_tab_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_daily"))

        # 日常任务选中态图标
        self.task_daily_tasks_select_icon = (By.XPATH, Personal.RESOURCE_ID.format("v_tab_daily_indicator"))

        # 成长任务tab
        self.task_growth_task_tab_btn = (By.XPATH , Personal.RESOURCE_ID.format("tv_grow"))

        # 成长任务选中态图标
        self.task_growth_tasks_select_icon = (By.XPATH, Personal.RESOURCE_ID.format("v_tab_grow_indicator"))

        # 活动任务tab
        self.task_active_task_tab_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_activity"))

        # 活动任务选中态图标
        self.task_activity_tasks_select_icon = (By.XPATH, Personal.RESOURCE_ID.format("v_tab_activity_indicator"))

         # 日常任务列表描述文本
        self.task_list_daily_task_description_text = (By.XPATH, Personal.punch_list_day_title_text.format(1))

         # 日常任务列表进度图标
        self.task_list_daily_task_schedule_icon = (By.XPATH, Personal.punch_list_day_progress_bar_img.format(1))

         # 日常任务列表完成按钮
        self.task_list_daily_task_done_btn = (By.XPATH, Personal.punch_list_day_done_btn.format(1))

        # 任务记录按钮
        self.task_mission_history_btn = (By.XPATH, Personal.RESOURCE_ID.format("tv_notes"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.task_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.task_back_btn)

    def get_list_day(self, index=1):
        """
        获取打卡天数文本

        :return: 获取元素
        """
        self.task_list_day_text = (By.XPATH, Personal.punch_list_day_text.format(index))
        return self.find_element_o(self.task_list_day_text)

    def get_list_day_punch(self, index=1):
        """
        获取打卡天数图标

        :return: 获取元素
        """
        self.task_list_day_punch_icon = (By.XPATH, Personal.punch_list_day_img.format(index))
        return self.find_element_o(self.task_list_day_punch_icon)

    def get_gold(self):
        """
        获取金币图标

        :return: 获取元素
        """
        return self.find_element_o(self.task_gold_img)

    def get_day_punch_prompt(self):
        """
        获取金币提示语

        :return: 获取元素
        """
        return self.find_element_o(self.task_day_punch_prompt_text)

    def click_punch_button(self):
        """
        点击打卡按钮

        :return: None
        """
        self.find_element_o(self.task_punch_button_btn)

    def get_keep_punching(self):
        """
        获取连续打卡提示

        :return: 获取元素
        """
        return self.find_element_o(self.task_keep_punching_text)

    def get_keep_punching_glod(self):
        """
        获取连续打卡角标

        :return: 获取元素
        """
        return self.find_element_o(self.task_keep_punching_glod_icon)

    def click_daily_tasks_tab(self):
        """
        点击日常任务按钮

        :return: None
        """
        self.click_element(self.task_daily_tasks_tab_btn)

    def get_daily_tasks_select(self):
        """
        获取日常任务选中态

        :return: 获取元素
        """
        return self.find_element_o(self.task_daily_tasks_select_icon)

    def click_growth_task_tab(self):
        """
        点击成长任务按钮

        :return: None
        """
        self.click_element(self.task_growth_task_tab_btn)

    def get_growth_tasks_select(self):
        """
        获取成长任务选中态

        :return: 获取元素
        """
        return self.find_element_o(self.task_growth_tasks_select_icon)

    def click_active_task_tab(self):
        """
        点击活动任务按钮

        :return: None
        """
        self.click_element(self.task_active_task_tab_btn)

    def get_activity_tasks_select(self):
        """
        获取活动任务选中态

        :return: 获取元素
        """
        return self.find_element_o(self.task_activity_tasks_select_icon)

    def get_list_daily_task_description(self, index=1):
        """
        获取日常任务描述

        :return: 获取元素
        """
        self.task_list_daily_task_description_text = (By.XPATH, Personal.punch_list_day_title_text.format(index))
        return self.find_element_o(self.task_list_daily_task_description_text)

    def get_list_daily_task_schedule(self, index=1):
        """
        获取进度条

        :return: 获取元素
        """
        self.task_list_daily_task_schedule_icon = (By.XPATH, Personal.punch_list_day_progress_bar_img.format(index))
        return self.find_element_o(self.task_list_daily_task_schedule_icon)

    def click_list_daily_task_done(self, index=1 ):
        """
        点击去完成按钮

        :return: None
        """
        self.task_list_daily_task_done_btn = (By.XPATH, Personal.punch_list_day_done_btn.format(index))
        self.click_element(self.task_list_daily_task_done_btn)

    def click_mission_history(self):
        """
        点击任务记录按钮

        :return: None
        """
        self.click_element(self.task_mission_history_btn)

    def is_display_personal_task(self):
        """
        是否进入任务中心界面

        :return: bool
        """
        return self.is_display(self.task_daily_tasks_tab_btn)

